package com.wrk._3_方法._02_习题;

import java.util.Arrays;
import java.util.Scanner;

public class _006_评委打分 {
    //6个评委打分
    //去掉最高，最低份
    //求剩下分数平均值
    public static void main(String[] args) {
        //定义新数组，赋值评委数量方法
        int[] array = getInts(6);
        //求平均值
        int sum = 0;
        for (int i = 0; i < array.length; i++) {
            sum += array[i];
        }
        int age = sum/array.length;
        System.out.println("平均分数为："+age);
    }
    private static int[] getInts(int number) {
        //创建输入流
        Scanner scanner = new Scanner(System.in);
        //输入分数，定义原始数组
        int [] arr = new int[number];
        //输入分数
        for (int i = 0; i < arr.length;) {
            System.out.print("请第"+(i+1)+"个评委打分：");
            int score = scanner.nextInt();
            if (score >=0 && score<=100){
                arr[i] = score;
                i++;
            }else {
                System.out.println("输入分数超出0-100范围,请重新输入");
            }
        }
        //数组排序
        Arrays.sort(arr);
        //剔除最大最值
        int[] array = Arrays.copyOfRange(arr,1,arr.length-1);
        return array;
    }
}